<?php

class Model_Ps_Psstock extends Zend_Db_Table_Abstract {

	protected $_name = 'ps_stock_available';
	protected $_adaptor = 'db_remote';
	protected $_primary = 'id_stock_available';
	
	public function getPsstock( $idStockAvailable){
		
		$row = $this->fetchRow("`id_stock_available` = ". $idStockAvailable);
		if(!$row) return false;
		return $row->toArray();		
		
		}
		
	public function addPsstock( $idProduct , $idProductAttribute , $idShop , $idShopGroup , $quantity , $dependsOnStock , $outOfStock){
		
		$data = array(
			
         "id_product" =>  $idProduct ,
         "id_product_attribute" =>  $idProductAttribute ,
         "id_shop" =>  $idShop ,
         "id_shop_group" =>  $idShopGroup ,
         "quantity" =>  $quantity ,
         "depends_on_stock" =>  $dependsOnStock ,
         "out_of_stock" =>  $outOfStock 
	
			);
		$this->insert($data);
		
		}
		
	public function updatePsstock(  $idStockAvailable ,  $idProduct , $idProductAttribute , $idShop , $idShopGroup , $quantity , $dependsOnStock , $outOfStock){
		$data = array(
			
         "id_product" =>  $idProduct ,
         "id_product_attribute" =>  $idProductAttribute ,
         "id_shop" =>  $idShop ,
         "id_shop_group" =>  $idShopGroup ,
         "quantity" =>  $quantity ,
         "depends_on_stock" =>  $dependsOnStock ,
         "out_of_stock" =>  $outOfStock 
	
			);
			
		$this->update($data,"`id_stock_available` = ". $idStockAvailable);
		}
		
	public function deletePsstock( $idStockAvailable){
		
		$this->delete("`id_stock_available` = ". $idStockAvailable);
		
		}	
	
	public function listAll(){
		
		$rows =$this->fetchAll("1","id_stock_available DESC ");
		if(!$rows) return false;
		return $rows->toArray();			
		
		}	
	public function updateStockQty($qty, $idStockAvailable ){
		
		$data = array(
				"quantity" =>  $qty
		);
			
		$this->update($data,"`id_stock_available` = ". $idStockAvailable);
	}	
}


?>